home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Generic Fax1&ARA < prev    next >
Text File  |  1994-02-10  |  7KB  |  344 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: Class 1 fax modem hardware handshaking cable.
  4.  
  5. !$ Supports: fax and ARA software in the server mode.
  6.  
  7. !$ Fax Receiving: if Adaptive Answering is implemented
  8.  
  9. !$ Use:   Class 1 for Fax, ARA/LineShare for ARA.
  10.  
  11. !$ Read:  your modem manual to modify the "AT" strings.
  12.  
  13. !$ See:   the Generic Scripts Guide for details.
  14.  
  15. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  16. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  17. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  18. ^5 Adaptive Answering:  = Text ""
  19. ^6 AT for Normal mode:  = Text ""
  20. ^7 AT for HW Handshake: = Text ""
  21. ^8 AT for SW Handshake: = Text ""
  22. ! ------------------------------------------
  23. ! Resetting the modem:
  24. ! ------------------------------------------
  25. @Hangup
  26.   SetTries 2
  27.   Flush
  28.   HsReset 0,0,17,19,0,0
  29. !
  30. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  31. ! to enter the command mode
  32. !
  33. @Label 1
  34.   matchclr
  35.   matchstr 1 2 "OK¥r¥n"
  36.   write "ATH0&FV1¥r"
  37.   matchread 20
  38.   ChrDelay 1
  39.   Write "+++"
  40.   ChrDelay 0
  41.   DtrClear
  42.   LBreak
  43.   DtrSet
  44. !
  45.   DecTries
  46.   IfTries 0 1
  47. !
  48. ! OSErr -6019 "Modem error - the modem is not responding"
  49. !
  50.   exit -6019
  51. @Label 2
  52.   write "AT+FCLASS=0¥r"
  53.   Jsr 100
  54.   ifStr 5 3 ""
  55.   write "AT^5¥48¥r"
  56.   Jsr 100
  57. @Label 3
  58.   exit 0
  59.  
  60. ! ------------------------------------------
  61. !    Receiving incoming calls
  62. ! ------------------------------------------
  63. @ANSWER
  64.   SetVar A ""
  65.   IfStr A 50 "^6^7^8"
  66. !
  67. ! Set the modem preferred speed first
  68. !
  69.   SerReset 19200,0,8,1
  70.   Jsr 80
  71.  
  72. @Label 10
  73. !
  74. ! Set the common options
  75.   Jsr 70
  76. !
  77. ! Set the communication options:
  78. ! ・ Normal connection, report connection speed (for ARA)
  79. ! ・ HW flow control   (for ARA, Fax should not use a handshake on receiving)
  80. !
  81.   Write "AT^7^6¥r"
  82.   Jsr 100
  83. !
  84. ! Set Fax mode & adaptive answering (if necessary)
  85. !
  86.   ifStr 5 15 ""
  87. !
  88.   Write "AT+FCLASS=1¥r"
  89.   Jsr 100
  90.   Write "AT^5¥49¥r"
  91.   Jsr 100
  92.   Write "AT+FCLASS=0¥r"
  93.   Jsr 100
  94. !
  95. ! Fetch the tube after ^4 rings
  96. ! Switch to numeric answers (for fax software)
  97. !
  98.   Write "ATS0=^4V0¥r"
  99.   Jsr 110
  100. !
  101. ! Everything is ready - let's sit and wait for a call
  102. ! We'll wait for 2 minutes, then reinitiate the modem
  103. !
  104.   Note "Waiting for a fax or ARA callノ"
  105.   MatchClr
  106.   MatchStr 02 40 "47¥r"
  107.   MatchStr 03 40 "10¥r"
  108.   MatchStr 04 41 "48¥r"
  109.   MatchStr 05 41 "11¥r"
  110.   MatchStr 06 42 "49¥r"
  111.   MatchStr 07 43 "50¥r"
  112.   MatchStr 08 43 "12¥r"
  113.   MatchStr 09 44 "51¥r"
  114.   MatchStr 10 44 "13¥r"
  115.   MatchStr 11 45 "52¥r"
  116.   MatchStr 15 31 "33¥r"
  117.   MatchStr 16 13 "2¥r"
  118.   MatchStr 17 30 "1¥r"
  119.   MatchStr 18 12 "3¥r"
  120.   MatchStr 19 12 "8¥r"
  121.   MatchStr 20 12 "7¥r"
  122. @Label 11
  123.   Matchread 1200
  124. @Label 12
  125.   Note "Tuning againノ"
  126.   Write "ATV1"
  127.   Jsr 100
  128.   Jump 10
  129. @Label 13
  130.   Note "Ringノ"
  131.   Jump 11
  132.  
  133. !
  134. ! No adaptive answering -> work in verbal mode (more reliable)
  135. !
  136. @Label 15
  137.   Write "ATS0=^4¥r"
  138.   Jsr 100
  139. !
  140.   Note "Waiting for an ARA callノ"
  141.   MatchStr 1 20 "¥r¥nCARRIER "
  142.   MatchStr 2 20 "¥r¥nCONNECT "
  143.   MatchStr 3 17 "¥r¥nRING¥r¥n"
  144.   MatchStr 4 10 "¥r¥nNO "
  145. @Label 16
  146.   Matchread 1200
  147.   jump 10
  148. @Label 17
  149.   Note "Ringノ"
  150.   jump 16
  151. !
  152. ! Data connection has been established (we read "CARRIER")
  153. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  154. ! if it was an incoming call, put the "RING" before the "CONNECT"
  155. !
  156. @Label 20
  157.   QueueInput "¥r¥nCARRIER "
  158.   ifOriginate 21
  159.   QueueInput "¥r¥nRING¥r¥n"
  160. @Label 21
  161.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  162. !
  163. ! Fax connection has been established (we read "FAX")
  164. ! Put the +FCON back to the buffer,
  165. ! if it was an incoming call, put the "RING" before the "+FCON"
  166. ! Attach the "Fax" subPort
  167. !
  168. @Label 30
  169.   QueueInput "1¥r"
  170.   ifOriginate 32
  171. @Label 31
  172.   QueueInput "2¥r2¥r"
  173. @Label 32
  174.   Attach "Fax" (Reset(2400),IdleLimit=30)
  175.  
  176. !
  177. ! Converting numeric responses into the verbal
  178. !
  179. @Label 40
  180.   QueueInput "2400¥r¥n"
  181.   Jump 20
  182. @Label 41
  183.   QueueInput "4800¥r¥n"
  184.   Jump 20
  185. @Label 42
  186.   QueueInput "7200¥r¥n"
  187.   Jump 20
  188. @Label 43
  189.   QueueInput "9600¥r¥n"
  190.   Jump 20
  191. @Label 44
  192.   QueueInput "12000¥r¥n"
  193.   Jump 20
  194. @Label 45
  195.   QueueInput "14400¥r¥n"
  196.   Jump 20
  197.  
  198. @Label 50
  199.   Note "Suspended"
  200.   Say "Press the Optionsノ button to enter the AT-strings for your modem!"
  201.   Pause 1200
  202.   Jump 50
  203.  
  204. ! ------------------------------------------
  205. ! Originating a call through the "ARA" subport
  206. ! ------------------------------------------
  207. @ORIGINATE "ARA"
  208.   SerReset 19200,0,8,1
  209.   Jsr 80
  210. !
  211. ! Set the common options
  212. !
  213.   Jsr 70
  214. !
  215. ! Set the Data mode:
  216. ! ・ Normal connection, report connection speed
  217. ! ・ HW Handshake
  218. !
  219.   Write "AT^6^7¥r"
  220.   Jsr 100
  221. !
  222. ! Prepare to receive all error result codes, dial the number
  223. !
  224.   Jsr 90
  225.   MatchStr 1 20 "¥r¥nCARRIER "
  226.   MatchStr 2 20 "¥r¥nCONNECT "
  227.   MatchRead 1000
  228.   Write "¥r"
  229.   Exit -6019
  230.  
  231. ! ------------------------------------------
  232. ! Originating a call through the "Fax" subPort
  233. ! ------------------------------------------
  234. @ORIGINATE "Fax" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  235. !
  236. ! Set the "Fax" speed
  237. !
  238.   SerReset 19200,0,8,1
  239.   Jsr 80
  240. !
  241. ! Set the common options
  242. !
  243.   Jsr 70
  244. !
  245. ! Set the Fax mode (Xon/Xoff)
  246.   Write "AT&S0^8+FCLASS=1¥r"
  247.   Jsr 100
  248. !
  249. ! Now emit all commands that the application has sent to that port,
  250. ! except "FCLASS", etc
  251. !
  252.   EmitClear "FCLASS","V","X","E"
  253.   Jsr 60
  254.   Write "ATV0¥r"
  255.   Jsr 110
  256. !
  257. ! Prepare to receive all error result codes, dial the number
  258. !
  259.   MatchClr
  260.   MatchStr 01 30 "1¥r"
  261.   MatchStr 13 93 "3¥r"
  262.   MatchStr 14 94 "8¥r"
  263.   MatchStr 15 92 "7¥r"
  264.   Write "ATD^1¥r"
  265.   HsReset *
  266.   MatchRead 1000
  267.   Write "¥r"
  268.   Exit -6019
  269. !
  270. ! This section emits all modem commands sent from the client application
  271. ! For each set of commands the "OK" answer is awaited
  272. !
  273. @Label 60
  274.   EmitStart
  275. @Label 61
  276.   EmitCommand 62
  277.   Jsr 100
  278.   Jump 61
  279. @Label 62
  280.   return
  281. !
  282. ! This section initiates the modem before ANSWER and ORIGINATEs:
  283. ! extended responses + connect at the highest rate + speaker control +
  284. ! reset on Dtr drop + DCD valid
  285. ! Verbal responses mode, no echo 
  286. !
  287. @Label 70
  288.   Write "ATX4M^2L^3&D2&C1V1E0¥r"
  289.   Jsr 100
  290.   return 
  291.  
  292. !
  293. ! This section syncronize the modem after the serial port speed switching
  294. !
  295. @Label 80
  296.   ChrDelay 1
  297.   Write "AT¥r"
  298.   ChrDelay 0
  299.   Jsr 100
  300.   return
  301. !
  302. ! Prepare to receive error result codes, send the dialing command and
  303. ! set the user's handshake mode
  304. !
  305. @Label 90
  306.   MatchClr
  307.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  308.   MatchStr 3 92 "BUSY¥r¥n"
  309.   MatchStr 4 93 "NO CARRIER¥r¥n"
  310.   MatchStr 5 94 "NO ANSWER¥r¥n"
  311.   Write "ATD^1¥r"
  312.   HsReset *
  313.   return
  314. @Label 91
  315.   exit -6020
  316. @Label 92
  317.   exit -6022
  318. @Label 93
  319.   exit -6021
  320. @Label 94
  321.   exit -6023
  322. !
  323. ! Processing the AT command:
  324. ! OK -> proceed
  325. ! ERROR or TimeOut ->exit -6019
  326. ! It can be called AFTER the "Write" command, since LineShare buffers input
  327. !
  328. @Label 100
  329.   MatchClr
  330.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  331.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  332. @Label 101
  333.   MatchRead 20
  334. @Label 102
  335.   Exit -6019
  336. @Label 103
  337.   return
  338.  
  339. @Label 110
  340.   MatchClr
  341.   MatchStr 1 103 "0¥r"
  342.   MatchStr 2 102 "4¥r"
  343.   Jump 101
  344.